<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"  />
</head>
<?php session_start(); 
include("dbconnect.php");	
include "smtp.php";  #Nho dac file smtp.php cùng thư mục với file contact.php
?>
<?
include_once $_SERVER['DOCUMENT_ROOT'] . '/thptnamsach/securimage/securimage.php';

$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
  // the code was incorrect
  // you should handle the error so that the form processor doesn't continue

  // or you can use the following code if there is no validation or you do not know how
  echo "Capcha nhập sai.<br /><br />";
  echo "Quay lại <a href='javascript:history.go(-1)'>đây</a> .";
  exit;
} else {
	$sql = "SELECT * FROM pageinfo WHERE name LIKE 'admin_email' ";
	$result=mysql_query($sql) or die("Can not query email admin ".mysql_error($conn));
	$row = mysql_fetch_array($result);
	$email_admin = $row['value'];
	if (isset($_POST['Company'])) $company = $_POST['Company'];
	else $company = "";
	if (isset($_POST['Fax'])) $fax = $_POST['Fax'];
	else $fax = "";
	$noidung = $_POST['Content'];
	$tieude = $_POST['Subject'];
	$sender = $_POST['FullName'];
	$email = $_POST['Email'];
	$phone = $_POST['Phone'];
	SendMail($email,$email_admin ,$tieude,$noidung,$sender);
	$sql="insert lienhe(tieude, thoigian,noidung,tencongty,tennguoigui,email,sofax,sodienthoai, status) values('$tieude', now() ,'$noidung', '$company','$sender','$email','$fax','$phone', $status)";
	$result=mysql_query($sql) or die("Can not insert y kien " .mysql_error($conn));
	echo "<script> alert('Gửi thành công'); location='lienhe.php';</script>";
#Ví dụ:  SendMail($_POST['mailfrom'],$_POST['mailto'],$_POST['subject'],$body,$_POST['sender']); 
}
?>

